package com.aaa.car.controller;

import com.aaa.car.entity.MaintainShop;
import com.aaa.common.util.Result;
import com.github.pagehelper.PageInfo;
import com.aaa.car.service.MaintainShopService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * (MaintainShop)表控制层
 *
 * @author YuXin
 * @since 2020-11-25 19:16:32
 */
@RestController
@RequestMapping("maintainShop")
public class MaintainShopController {
    /**
     * 服务对象
     */
    @Resource
    private MaintainShopService maintainShopService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("queryById")
    public MaintainShop queryById(Integer id) {
        return this.maintainShopService.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param pageNo       查询当前页
     * @param pageSize     查询每页条数
     * @param maintainShop 对象实体
     * @return 对象列表
     */
    @GetMapping("queryAllByParam")
    public Result queryAllByParam(Integer pageNo, Integer pageSize, MaintainShop maintainShop) {
        return this.maintainShopService.queryAllByParam(pageNo, pageSize, maintainShop);
    }

    /**
     * 查询多条数据
     *
     * @return 对象列表
     */
    @GetMapping("queryAll")
    public Result queryAll() {
        return this.maintainShopService.queryAll();
    }

    /**
     * 新增数据
     *
     * @param maintainShop 实例对象
     * @return 实例对象
     */
    @PostMapping("insert")
    public MaintainShop insert(@RequestBody MaintainShop maintainShop) {
        maintainShop.setAddtime(new Date());
        this.maintainShopService.insert(maintainShop);
        return maintainShop;
    }

    /**
     * 修改数据
     *
     * @param maintainShop 实例对象
     * @return 实例对象
     */
    @PutMapping("update")
    public MaintainShop update(@RequestBody MaintainShop maintainShop) {
        return this.maintainShopService.update(maintainShop);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @DeleteMapping("deleteById")
    public boolean deleteById(Integer id) {
        return this.maintainShopService.deleteById(id);
    }
}